package com.hwd.srb.core.enmu;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.Arrays;

/**
 * @author 黄伟东/Victor
 * @date 2022/3/25 11:27
 * @Description 借款人积分信息枚举类
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum IntegralEnum {

    BORROWER_INFO(50, "借款人基本信息积分"),
    BORROWER_ID_CARD(30, "借款人身份证信息积分"),
    BORROWER_HOUSE(100, "借款人房产信息积分"),
    BORROWER_CAR(60, "借款人车辆信息积分"),
    ;

    @EnumValue
    private Integer integral;

    @JsonValue
    private String content;

    @Override
    public String toString() {
        return this.content;
    }

    public static String getContentByIntegral(int integral) {
        return Arrays.stream(IntegralEnum.values())
                .filter(i -> i.getIntegral() == integral)
                .map(IntegralEnum::getContent)
                .findFirst()
                .orElse("");
    }
}
